package com.jt.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jt.client.AccountFeign;
import com.jt.client.DingDanFeign;
import com.jt.mapper.OrderMapper;
import com.jt.pojo.Order;
import com.jt.service.OrderService;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {
    @Autowired
    private  OrderMapper orderMapper;
    @Autowired
    private AccountFeign accountFeign;
    @Autowired
    private DingDanFeign dingDanFeign;
    @Override
    @GlobalTransactional
    public boolean insertOrder(Order order) {
        orderMapper.insert(order);
        try {
            accountFeign.deleteAccount(order.getUserId(),order.getCount());
            
        }catch (Exception e){
            log.error(e.getMessage());
        }
        return false;
    }
}
